package com.itheima;

//定义int类型的数组, 存储数据: 11, 33, 22, 55, 44, 对数组元素进行反转, 并打印反转后的结果.
public class Demo04 {
    public static void main(String[] args) {
        //1. 定义int类型的数组, 存储数据:  11, 22, 33, 44, 55
        int[] arr = {11, 22, 33, 44, 55, 66};
        //2. 反转数组, 并打印反转后的结果: 66,55, 44, 33, 22, 11
        for (int i = 0; i < arr.length / 2; i++) {
            //arr[i] 和 arr[arr.length - 1 - i]交换.
            int temp = arr[i];
            arr[i] = arr[arr.length - 1 - i];
            arr[arr.length - 1 - i] = temp;
        }
        //3. 打印结果, 即: 遍历数组.
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}
